<template>
    <div class="list-container">
      <ul>
        <li v-for="(item, index) in list" :key="index" @click="selectItem(item)">
          {{ item.label }}
        </li>
      </ul>
    </div>
  </template>
  
  <script>
  export default {
    name: 'List',
    props: {
      list: {
        type: Array,
        required: true,

      }
    },
    data(){
      return {
        classObj:{
          select:false
        }
      }
    },
    methods: {
      selectItem(item) {
        this.$emit('select', item);
      }
    },
    mounted() {
      let li = document.querySelectorAll('li');
      for (let i = 0; i < li.length; i++) {
        li[i].onclick=function(){
          for (let i = 0; i < li.length; i++){
            li[i].className='';
          }
          this.className='select';
        }
      }
    }
  }
  </script>
  
  <style scoped>
  .list-container {
    background-color: #0a1c3b;
    border-radius: 5px;
    border: 2px solid #00b3ff;
    padding: 10px;
  }
  
  ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
  }
  
  li {
    color: #fff;
    padding: 10px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: transform 0.2s ease-in-out;
  }
  
  li:hover {
    background-color: #4d5b84;
    transform: scale(1.01);
  }
  
  li:first-child {
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
  }
  
  li:last-child {
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
  }
  li:active {
  box-shadow: inset 0px 0px 2px rgba(0, 0, 0, 0.5);
  transform: scale(0.99);
}
  .select{
    background-color: #4d5b84;
    transform: scale(1.01);
  }
  </style>